package com.wanmait.baohan.filter;

import com.wanmait.baohan.util.SysContext;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

@WebFilter("/d000")
public class DemoFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        Integer pageNum = null;

        try {
            pageNum = Integer.parseInt(servletRequest.getParameter("pageNum"));

        } catch (NumberFormatException e) {
            pageNum=1;
        }
        SysContext.setPageNum(pageNum);
        try {
            filterChain.doFilter(servletRequest, servletResponse);
        }
        finally {
            SysContext.clear();
        }

    }
}
